<template>
  <d2-container>
    <el-form :model="FormSearch" status-icon label-width="100px" class="demo-ruleForm">
      
    </el-form>
    <!-- 数据表格 -->
    <d2-crud
      ref="d2Crud"
      :columns="columns"
      :data="data"
      :pagination="page"
      @pagination-current-change="paginationCurrentChange"
    />
  </d2-container>
</template>

<script>
import { merchantSalesReport } from "@/api/goods/index";
import util from '@/libs/util.js'
// 查看图片组件
import good_img from "@/components/xtnComponents/Good_img";

export default {
  data() {
    return {
      // 搜索数据
      FormSearch: {
        name: "",
        order_on: "",
        startTime: "",
        endTime: "",
        order_status: ""
      },
      // 字段名称
      columns: [
        {
          title: "经销商ID",
          key: "jxsid",
          align: "center"
        },
        {
          title: "经销商名称",
          key: "jxsmc",
          align: "center"
        },
        {
          title: "商品名称",
          key: "fname",
          align: "center"
        },
        {
          title: "商品图片",
          key: "fimage",
          align: "center",
          component: {
            name: good_img
          }
        },
        {
          title: "经销商库存",
          key: "zstock",
          align: "center"
        },
      ],
      // 列表数据
      data: [],
      // 分页数据
      page: {
        total: 0,
        pageIndex: 1,
        pageSize: 10
      }
    };
  },
  created() {
    console.log(this.$route.query);
    let params = {
      page: this.page.pageIndex,
      limit: this.page.pageSize
    };
    this.init(params);
  },
  methods: {
    // 初始化身体数据列表
    init(params) {
      params.wpid = this.$route.query.fid
      params.id = util.cookies.get('uuid')
      merchantSalesReport(params)
        .then(res => {
          if (res.success) {
            this.data = res.rows;
            this.page.total = res.total;
          }
        })
        .catch(err => {
          this.$message.error(err);
        });
    },

    // 分页数改变，调用
    paginationCurrentChange(pageIndex) {
      let params = {
        limit: this.page.pageSize,
        good: this.FormSearch.good
      };
      params.page = this.page.pageIndex = pageIndex;
      this.init(params);
    },

    // 条件查询搜索
    searchClick() {
      let params = {};
      params = this.FormSearch;
      params.page = 1;
      console.log(params);
      this.init(params);
    },

    // 重置查询
    resetForm() {
      this.FormSearch.good = "";
      let params = {
        page: 1,
        limit: 10
      };
      this.init(params);
    }
  }
};
</script>

<style lang="scss" scoped>
</style>